package com.pingan.haofang.searchcloud.solr.constants;

import java.util.HashMap;
import java.util.Map;

import com.pingan.haofang.searchcloud.api.query.parser.dbobject.FunctionConfig;
import com.pingan.haofang.searchcloud.api.query.parser.dbobject.sqlnode.function.Function;

public class SolrExpression {

    public static final Map<Class<? extends Function>, String> MAP = new HashMap<>();

    static {
        MAP.put(FunctionConfig.COUNT.functionClass, "count");
        MAP.put(FunctionConfig.MAX.functionClass, "max");
        MAP.put(FunctionConfig.MIN.functionClass, "min");
        MAP.put(FunctionConfig.AVG.functionClass, "avg");
        MAP.put(FunctionConfig.SUM.functionClass, "sum");
        MAP.put(FunctionConfig.COUNT_DISTINCT.functionClass, "unique");
    }

    public static String getExpression(Function function) {
        return MAP.get(function.getClass());
    }
}
